package com.tanhua.controller;

import com.tanhua.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.sql.ResultSet;

@RestController
@RequestMapping(value = "/manage")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping(value ="/users",name = "分页查询用户列表")
    public ResponseEntity users(Integer page,Integer pagesize){

        return userService.findUsers(page,pagesize);
    }
    @GetMapping(value ="/users/{userID}",name = "根据用户id做用户详情展示")
    public ResponseEntity findByUserId(@PathVariable("userID") Long userId){
        return userService.findByUserId(userId);
    }
    @GetMapping(value ="/videos",name = "分页查询用户的小视频列表")
    public ResponseEntity findUserVideo(@RequestParam(defaultValue = "1") Integer page,
                                        @RequestParam(defaultValue = "10") Integer pagesize,
                                        Long uid){
        return userService.findUserVideo(page,pagesize,uid);
    }
    @GetMapping(value = "/messages",name="分页查询用户的动态列表")
    public ResponseEntity findMessages(Integer page,Integer pagesize,Long uid,
                                       Integer state) throws IOException {

        return userService.findMessages(page,pagesize,uid,state);
    }
    @GetMapping(value = "/messages/{id}",name = "查询动态详情")
    public ResponseEntity findPublishInfo(@PathVariable("id") String publishId){
        return userService.findPublishInfo(publishId);
    }

    @GetMapping(value = "/messages/comments",name = "指定圈子动态的评论")
    public ResponseEntity findPublishComment(@RequestParam(defaultValue = "1") Integer page,
                                            @RequestParam(defaultValue = "10") Integer pagesize,
                                            String messageID){

        return userService.findPublishComment(page,pagesize,messageID);
    }
}